function windowsclass(clikeclass, opendivclass, clikeclass02, opendivclass02, vallist, taplen, stylename, overstylename) {
    $(clikeclass).removeClass(overstylename).addClass(stylename);
    $(opendivclass).show();
    var openid = '';
    var opendivid = '';
    for (i = 1; i <= taplen; i++) {
        if (i != vallist) {
            openid = openid + '#' + clikeclass02 + i + ',';
            opendivid = opendivid + '#' + opendivclass02 + i + ','
        }
    }
    openid = openid + '#neiow';
    opendivid = opendivid + '#neiow';
    $(opendivid).hide();
    $(openid).removeClass(stylename).addClass(overstylename)
}
function sessionimg(inputname, url) {
    var imgtitle = url + 'public/seccode.php?rd=' + Math.random();
    $("#" + inputname).attr("src", 
    function() {
        return imgtitle
    })
}
function memberlogin(seccodetype) {
    if (document.mainform.username.value == "") {
        document.mainform.username.focus();
        alert(username_empty);
        return false
    }
    if (document.mainform.password.value == "" || document.mainform.password.value < 5) {
        document.mainform.password.focus();
        alert(password_empty);
        return false
    }
    if (seccodetype == '1' && document.mainform.seccode.value.match(/^[A-Z]{4}$/ig) == null) {
        document.mainform.seccode.focus();
        alert(seccode_empty);
        return false
    }
}
function checktypename(dbname, value, loadurl, gettxtid, okmess, nomess, bottonname) {
    var um = document.getElementById(gettxtid);
    var nullstr = "手机号为空或者手机号格式错误";
	var nullemail = "email为空或者emial格式错误";
	var nullstr2 = "不能为空";
	if(dbname == "username") {
		if (value == '' || !document.memberreg.username.value.match(/^1\d{10}$/)) {
			um.innerHTML = "<font color=\"red\">" + nullstr + "</font>";
			$("#chkuser").val("false");
			$('#' + bottonname).attr('disabled', 'true');
			return false
		}
	} else if(dbname == "email") {
		if (value == '' || !document.memberreg.email.value.match(/^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/)) {
			um.innerHTML = "<font color=\"red\">" + nullemail + "</font>";
			$("#chkemail").val("false");
			$('#' + bottonname).attr('disabled', 'true');
			return false
		}
	} else {
		if (value == '') {
			um.innerHTML = "<font color=\"red\">" + nullstr2 + "</font>";
			$('#' + bottonname).attr('disabled', 'true');
			return false
		}
	}
    $.ajax({
        type: "POST",
        url: loadurl,
        data: dbname + "=" + value,
        success: function(date) {
            if (date == "false") {
                um.innerHTML = "<font color=\"red\">" + nomess + "</font>";
                $('#' + bottonname).attr('disabled', 'true')
				if(dbname=="username") {
					$("#chkuser").val("false");
				} else {
					$("#chkemail").val("false");
				}
            } else {
                um.innerHTML = "<font color=\"#1CB521\">" + okmess + "</font>";
				if(dbname=="username") {
					$("#chkuser").val("true");
				} else {
					$("#chkemail").val("true");
				}
                $('#' + bottonname).attr('disabled', '')
            }
        }
    })
}
function memberdbreg() {
    if (!document.memberreg.username.value.match(/^1\d{10}$/)) {
        alert(username_len);
        document.memberreg.username.focus();
        return false
    }
    if (!document.memberreg.email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/ig)) {
        alert(email_match);
        document.memberreg.email.focus();
        return false
    }
    if (document.memberreg.password.value.length < 6 || document.memberreg.password.value.length > 20) {
        alert(password_len);
        document.memberreg.password.focus();
        return false
    }
    if (document.memberreg.password.value == "123456" || document.memberreg.password.value == "111111" || document.memberreg.password.value == "aaaaaa" || document.memberreg.password.value == "654321" || document.memberreg.password.value == "abcdef") {
        alert(password_len2);
        document.memberreg.password.focus();
        return false
    }
    if (document.memberreg.username.value == document.memberreg.password.value) {
        alert(password_len2);
        document.memberreg.password.focus();
        return false
    }
    if (document.memberreg.password2.value == "") {
        alert(password2_empty);
        document.memberreg.password2.focus();
        return false
    }
    if (document.memberreg.password2.value != document.memberreg.password.value) {
        alert(password_disaffinity);
        document.memberreg.password.focus();
        return false
    }
	if (document.memberreg.alias.value =="" || document.memberreg.alias.value.length >20) {
        alert("姓名不能为空，请输入你的姓名");
        document.memberreg.alias.focus();
        return false
    }
    if (!document.getElementById("agree").checked) {
        alert(agree_empty);
        return false
    }
	var chkuser = $("#chkuser").val();
	var chkemail = $("#chkemail").val();
	if(chkuser == "false" ) {
		var usermsg = $("#usermsg").text();
		alert(usermsg);
		return false;
	}
	if(chkemail == "false") {
		var mailmsg = $("#mailmsg").text();
		alert(mailmsg);
		return false;
	}
}
function editpassword() {
    if (document.editmember.oldpassword.value == "" || document.editmember.oldpassword.value.length < 6) {
        alert(oldpassword_err);
        document.editmember.oldpassword.focus();
        return false
    }
    if (document.editmember.password.value.length < 6 || document.editmember.password.value.length > 20) {
        alert(password_len);
        document.editmember.password.focus();
        return false
    }
    if (document.editmember.password.value == "123456" || document.editmember.password.value == "111111" || document.editmember.password.value == "aaaaaa" || document.editmember.password.value == "654321" || document.editmember.password.value == "abcdef") {
        alert(password_len2);
        document.editmember.password.focus();
        return false
    }
    if (document.editmember.password2.value == "") {
        alert(password2_empty);
        document.editmember.password2.focus();
        return false
    }
    if (document.editmember.password2.value != document.editmember.password.value) {
        alert(password_disaffinity);
        document.editmember.password.focus();
        return false
    }
}
function editmail() {
    if (document.editmember.password.value == "" || document.editmember.password.value.length < 6) {
        alert(password_len);
        document.editmember.password.focus();
        return false
    }
    if (!document.editmember.email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) {
        alert(email_match);
        document.editmember.email.focus();
        return false
    }
}
function lostpassword(seccodetype) {
    if (!document.memberreg.username.value.match(/^1\d{10}$/)) {
        document.lostpassworddb.username.focus();
        alert(username_empty);
        return false
    }
	/**
    if (!document.lostpassworddb.email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) {
        alert(email_match);
        document.lostpassworddb.email.focus();
        return false
    }**/
    if (seccodetype == '1' && document.lostpassworddb.seccode.value.match(/^[A-Z]{4}$/ig) == null) {
        document.lostpassworddb.seccode.focus();
        alert(seccode_empty);
        return false
    }
}
function forumcreat(seccodetype) {
    if (document.bbsmainform.title.value == "") {
        alert(title_empty);
        document.bbsmainform.title.focus();
        return false
    }
    if (document.bbsmainform.blid.value == 0) {
        alert(btid_empty);
        document.bbsmainform.blid.focus();
        return false
    }
    var content = tinyMCE.get('content').getContent();
    if (content.length < 20) {
        alert(content_empty);
        return false
    }
    if (seccodetype == '1' && document.bbsmainform.seccode.value.match(/^[A-Z]{4}$/ig) == null) {
        document.bbsmainform.seccode.focus();
        alert(seccode_empty);
        return false
    }
}
function editinfo() {
    if (document.editmember.birthday.value != "") {
        if (document.editmember.birthday.value.match(/^[1-9][0-9]{3}\-[0-9]{2}\-[0-9]{2}$/ig) == null) {
            document.editmember.birthday.focus();
            alert(birthday_empty);
            return false
        }
    }
    if (document.editmember.zipcode.value != "") {
        if (document.editmember.zipcode.value.match(/^[0-9]+$/ig) == null) {
            document.editmember.zipcode.focus();
            alert(zipcode_empty);
            return false
        }
    }
    if (document.editmember.qq.value != "") {
        if (document.editmember.qq.value.match(/^[0-9]+$/ig) == null) {
            document.editmember.qq.focus();
            alert(qq_empty);
            return false
        }
    }
}
function orderamount(id) {
    var amout = document.getElementById("amount" + id);
    var amountvalue = document.getElementById("amount" + id).value;
    if (amountvalue.match(/^[1-9]{1}[0-9]*$/ig) == null) {
        alert(order_amout_err);
        amout.value = '1';
        return false
    }
}
function ordersave() {
    if (document.ordersaveform.alias.value == "") {
        document.ordersaveform.alias.focus();
        alert(alias_empty);
        return false
    }
    if (!document.ordersaveform.email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) {
        alert(email_err);
        document.ordersaveform.email.focus();
        return false
    }
    if (document.ordersaveform.cityone.value == 0 || document.ordersaveform.citytwo.value == 0 || document.ordersaveform.citythree.value == 0) {
        alert(count_city_err);
        return false
    }
    if (document.ordersaveform.address.value == "") {
        document.ordersaveform.address.focus();
        alert(address_title);
        return false
    }
    if (document.ordersaveform.zipcode.value != "") {
        if (document.ordersaveform.zipcode.value.match(/^[0-9]+$/ig) == null) {
            document.ordersaveform.zipcode.focus();
            alert(zipcode_empty);
            return false
        }
    }
    if (document.ordersaveform.tel.value == "" && document.ordersaveform.mobile.value == "") {
        document.ordersaveform.tel.focus();
        alert(tel_empty);
        return false
    }
}
function enquirysave() {
    if (document.mainform.linkman.value == "") {
        document.mainform.linkman.focus();
        alert(alias_empty);
        return false
    }
    if (!document.mainform.email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) {
        alert(email_err);
        document.mainform.email.focus();
        return false
    }
    if (document.mainform.cityone.value == 0 || document.mainform.citytwo.value == 0 || document.mainform.citythree.value == 0) {
        alert(count_city_err);
        return false
    }
    if (document.mainform.address.value == "") {
        document.mainform.address.focus();
        alert(address_title);
        return false
    }
    if (document.mainform.zipcode.value != "") {
        if (document.mainform.zipcode.value.match(/^[0-9]+$/ig) == null) {
            document.mainform.zipcode.focus();
            alert(zipcode_empty);
            return false
        }
    }
    if (document.mainform.tel.value == "" && document.mainform.mobile.value == "") {
        document.mainform.tel.focus();
        alert(tel_empty);
        return false
    }
}